﻿using System;

namespace Co9320.NamaAlert.Shared
{
	public class LiveInfo : IEquatable<LiveInfo>
	{
		public LiveInfo(string StationId, string Caster)
		{
			if (StationId == null)
			{
				throw new ArgumentNullException("StationId");
			}

			if (Caster == null)
			{
				throw new ArgumentNullException("Caster");
			}

			if (StationId.Trim().Length == 0 || Caster.Trim().Length == 0)
			{
				throw new ArgumentException();
			}

			this.StationId = StationId;
			this.Caster = Caster;
		}

		public string StationId
		{
			get;
			private set;
		}

		public string Caster
		{
			get;
			private set;
		}

		public override bool Equals(object obj)
		{
			if (obj.GetType() != typeof(LiveInfo))
			{
				return false;
			}

			if (obj == null)
			{
				return false;
			}

			return this == (LiveInfo)obj;
		}

		public override int GetHashCode()
		{
			return this.Caster.GetHashCode() ^ this.StationId.GetHashCode();
		}

		public override string ToString()
		{
			return string.Format("StationId:{0} Caster:{1}", this.StationId, this.Caster);
		}

		public static bool operator ==(LiveInfo Lp, LiveInfo Rp)
		{
			if (((object)Lp) == null && ((object)Rp) == null)
			{
				return true;
			}
			else if (((object)Lp) == null || ((object)Rp) == null)
			{
				return false;
			}
			else
			{
				return (Lp.Caster == Rp.Caster && Lp.StationId == Rp.StationId);
			}

		}

		public static bool operator !=(LiveInfo Lp, LiveInfo Rp)
		{
			return !(Lp == Rp);
		}





		#region IEquatable<LiveInfo> メンバ

		public bool Equals(LiveInfo other)
		{
			return this == other;
		}

		#endregion
	}
}